%code const cIndentString = '   '; // the trailing space is required for IE var AShowCounts: Boolean; function StringRepeat(AString: WideString; ARepeat: Integer): WideString; var i: Integer; begin result := toWideString(''); for i := 1 to ARepeat do result := result + AString; end; function FormatResult (AGUID: String; AName: WideString; ACount: Integer); begin result := toWideString(''); result := result + ''; if AShowCounts then result := result + WideFormat ('%s [%d]', [AName, ACount]) else result := result + AName; result := result + ''; end; var AParentGUID: String; ALink: WideString; ALevel: Integer; ACats: TCatalogPropCategories; ACat: TCatalogPropCategory; ACatParent: Boolean; AProps: TCatalogItemProps; AParent, AProp: TCatalogItemProp; i: Integer; AExpand: Boolean; begin result := toWideString(''); AShowCounts := (Request.Params.Values['showCounts'] = 'y'); AParentGUID := Trim(Request.Params.Values['GUID']); if AParentGUID = '' then AParentGUID := 'top'; AExpand := Request.Params.Values['expand'] ='y'; if not IsValidNumberString(Request.Params.Values['level'], False) then ALevel := 0 else ALevel := StrToInt(Request.Params.Values['level']); if AParentGUID = 'top' then begin ACats := TCatalogPropCategories.Create (TCatalogPropCategory, ''); Catalog.EnumCategories (ACats, AShowCounts); for i := 0 to ACats.Count - 1 do begin ACat := ACats.Items[i]; ALink := 'javascript:getHTML(''%var:PageOffset/./modules/labeltree.psc'', ''' + ACat.GUID + ''', ''GUID=' + ACat.GUID + '&showCounts=' + iif(AShowCounts, 'y', 'n') + '&expand=y&level=' + IntToStr(ALevel + 1) + ''')'; result := result + '
'; if Catalog.CategoryHasSubs (ACat) then begin result := result + '' + ' ' + ' ' + '' + ACat.CategoryName + '' + ''; end else result := result + ' ' + ACat.CategoryName + '
'; result := result + '
'; end; ACats.Free; end else begin ACatParent := False; AParent := TCatalogItemProp.Create(nil); if ALevel = 1 then begin ACat := TCatalogPropCategory.Create(nil); if Catalog.EnumCategory (AParentGUID, ACat, AShowCounts) then begin AParent.GUID := ACat.GUID; AParent.PropName := ACat.CategoryName; AParent.PhotoCount := ACat.PhotoCount; ACatParent := True; end; ACat.Free; end else begin Catalog.EnumProp (AParentGUID, AParent, AShowCounts); end; if AExpand then begin if ACatParent then ALink := 'javascript:getHTML(''%var:PageOffset/./modules/labeltree.psc'', ''' + AParent.GUID + ''', ''GUID=' + AParent.GUID + '&showCounts=' + iif(AShowCounts, 'y', 'n') + '&expand=n&level=' + IntToStr(ALevel) + ''')' else ALink := 'javascript:getHTML(''%var:PageOffset/./modules/labeltree.psc'', ''' + AParent.GUID + ''', ''GUID=' + AParent.GUID + '&showCounts=' + iif(AShowCounts, 'y', 'n') + '&expand=n&level=' + IntToStr(ALevel) + ''')'; result := result + StringRepeat(cIndentString, ALevel - 1) + '' + ' ' + ' ' + iif (ACatParent, '' + AParent.PropName + '', FormatResult(AParent.GUID, AParent.PropName, AParent.PhotoCount) ) + ''; { result := result + StringRepeat(cIndentString, ALevel - 1) + '' + ' ' + ' ' + FormatResult(AParent.GUID, AParent.PropName, AParent.PhotoCount) + '' } end else begin if ACatParent then ALink := 'javascript:getHTML(''%var:PageOffset/./modules/labeltree.psc'', ''' + AParent.GUID + ''', ''GUID=' + AParent.GUID + '&showCounts=' + iif(AShowCounts, 'y', 'n') + '&expand=y&level=' + IntToStr(ALevel) + ''')' else ALink := 'javascript:getHTML(''%var:PageOffset/./modules/labeltree.psc'', ''' + AParent.GUID + ''', ''GUID=' + AParent.GUID + '&showCounts=' + iif(AShowCounts, 'y', 'n') + '&expand=y&level=' + IntToStr(ALevel) + ''')'; result := result + StringRepeat(cIndentString, ALevel - 1) + '' + ' ' + ' ' + iif (ACatParent, '' + AParent.PropName + '', FormatResult(AParent.GUID, AParent.PropName, AParent.PhotoCount) ) + ''; end; if AExpand then begin AProps := TCatalogItemProps.Create (TCatalogItemProp, ''); Catalog.EnumPropsForParent (AParentGUID, AProps, False, AShowCounts); for i := 0 to AProps.Count - 1 do begin AProp := AProps.Items[i]; result := result + '
'; if Catalog.PropHasSubs (AProp) then begin result := result + StringRepeat(cIndentString, ALevel) + '' + ' ' + ' ' + FormatResult(AProp.GUID, AProp.PropName, AProp.PhotoCount) + ''; end else result := result + StringRepeat(cIndentString, ALevel) + ' ' + FormatResult(AProp.GUID, AProp.PropName, AProp.PhotoCount) + '
'; result := result + '
'; end; AProps.Free; end; AParent.Free; end; end; %/code